<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TProjectContract" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TProjectContract" type="EIA.PM.Model.TProjectContract, EIA.PM.Model" />
</alias>

<resultMaps>
<resultMap id="select-tprojectcontract-result" class="TProjectContract">
<constructor>
    <argument argumentName="contract_id" column="contract_id"/>
    <argument argumentName="prj_id" column="prj_id"/>
    <argument argumentName="contract_no" column="contract_no"/>
    <argument argumentName="signed_date" column="signed_date"/>
    <argument argumentName="valid_date" column="valid_date"/>
    <argument argumentName="invested_amount" column="invested_amount"/>
    <argument argumentName="contract_amount" column="contract_amount"/>
    <argument argumentName="prj_contract_signed_as" column="prj_contract_signed_as"/>
    <argument argumentName="prj_work_amount_rate" column="prj_work_amount_rate"/>
    <argument argumentName="prj_contract_amount_rate" column="prj_contract_amount_rate"/>
    <argument argumentName="_date" column="_date"/>
    <argument argumentName="_staff" column="_staff"/>
</constructor>
<!--
    <result property="ContractId" column="contract_id"/>
    <result property="PrjId" column="prj_id"/>
    <result property="ContractNo" column="contract_no"/>
    <result property="SignedDate" column="signed_date"/>
    <result property="ValidDate" column="valid_date"/>
    <result property="InvestedAmount" column="invested_amount"/>
    <result property="ContractAmount" column="contract_amount"/>
    <result property="PrjContractSignedAs" column="prj_contract_signed_as"/>
    <result property="PrjWorkAmountRate" column="prj_work_amount_rate"/>
    <result property="PrjContractAmountRate" column="prj_contract_amount_rate"/>
    <result property="Date" column="_date"/>
    <result property="Staff" column="_staff"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TProjectContract_where_pk">
WHERE contract_id=#ContractId#
</sql>

<sql id="sql_TProjectContract_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="ContractId" prepend="AND">contract_id=#ContractId#</isPropertyAvailable>
    <isPropertyAvailable property="PrjId" prepend="AND">prj_id=#PrjId#</isPropertyAvailable>
    <isPropertyAvailable property="ContractNo" prepend="AND">contract_no LIKE concat('%', #ContractNo#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="SignedDate" prepend="AND">signed_date=#SignedDate#</isPropertyAvailable>
    <isPropertyAvailable property="ValidDate" prepend="AND">valid_date=#ValidDate#</isPropertyAvailable>
    <isPropertyAvailable property="InvestedAmount" prepend="AND">invested_amount=#InvestedAmount#</isPropertyAvailable>
    <isPropertyAvailable property="ContractAmount" prepend="AND">contract_amount=#ContractAmount#</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractSignedAs" prepend="AND">prj_contract_signed_as=#PrjContractSignedAs#</isPropertyAvailable>
    <isPropertyAvailable property="PrjWorkAmountRate" prepend="AND">prj_work_amount_rate=#PrjWorkAmountRate#</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractAmountRate" prepend="AND">prj_contract_amount_rate=#PrjContractAmountRate#</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend="AND">_date=#Date#</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend="AND">_staff=#Staff#</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TProjectContract_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="PrjId" prepend=",">prj_id=#PrjId#</isPropertyAvailable>
    <isPropertyAvailable property="ContractNo" prepend=",">contract_no=#ContractNo#</isPropertyAvailable>
    <isPropertyAvailable property="SignedDate" prepend=",">signed_date=#SignedDate#</isPropertyAvailable>
    <isPropertyAvailable property="ValidDate" prepend=",">valid_date=#ValidDate#</isPropertyAvailable>
    <isPropertyAvailable property="InvestedAmount" prepend=",">invested_amount=#InvestedAmount#</isPropertyAvailable>
    <isPropertyAvailable property="ContractAmount" prepend=",">contract_amount=#ContractAmount#</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractSignedAs" prepend=",">prj_contract_signed_as=#PrjContractSignedAs#</isPropertyAvailable>
    <isPropertyAvailable property="PrjWorkAmountRate" prepend=",">prj_work_amount_rate=#PrjWorkAmountRate#</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractAmountRate" prepend=",">prj_contract_amount_rate=#PrjContractAmountRate#</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend=",">_date=#Date#</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend=",">_staff=#Staff#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTProjectContract" parameterClass="" resultMap="TProjectContract.select-tprojectcontract-result">
SELECT *
FROM t_project_contract
<include refid="sql_TProjectContract_where_pk"/><!--where-->
</select>

<select id="SelectTProjectContract_CV" parameterClass="System.Collections.IDictionary" resultMap="TProjectContract.select-tprojectcontract-result">
SELECT *
FROM t_project_contract
<include refid="sql_TProjectContract_where_cv"/><!--where-->
</select>

<insert id="InsertTProjectContract" parameterClass="TProjectContract">
<!--pre selectKey place-->
INSERT INTO t_project_contract(
<dynamic prepend=" ">
    <isPropertyAvailable property="PrjId" prepend=",">prj_id</isPropertyAvailable>
    <isPropertyAvailable property="ContractNo" prepend=",">contract_no</isPropertyAvailable>
    <isPropertyAvailable property="SignedDate" prepend=",">signed_date</isPropertyAvailable>
    <isPropertyAvailable property="ValidDate" prepend=",">valid_date</isPropertyAvailable>
    <isPropertyAvailable property="InvestedAmount" prepend=",">invested_amount</isPropertyAvailable>
    <isPropertyAvailable property="ContractAmount" prepend=",">contract_amount</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractSignedAs" prepend=",">prj_contract_signed_as</isPropertyAvailable>
    <isPropertyAvailable property="PrjWorkAmountRate" prepend=",">prj_work_amount_rate</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractAmountRate" prepend=",">prj_contract_amount_rate</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend=",">_date</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend=",">_staff</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="PrjId" prepend=",">#PrjId#</isPropertyAvailable>
    <isPropertyAvailable property="ContractNo" prepend=",">#ContractNo#</isPropertyAvailable>
    <isPropertyAvailable property="SignedDate" prepend=",">#SignedDate#</isPropertyAvailable>
    <isPropertyAvailable property="ValidDate" prepend=",">#ValidDate#</isPropertyAvailable>
    <isPropertyAvailable property="InvestedAmount" prepend=",">#InvestedAmount#</isPropertyAvailable>
    <isPropertyAvailable property="ContractAmount" prepend=",">#ContractAmount#</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractSignedAs" prepend=",">#PrjContractSignedAs#</isPropertyAvailable>
    <isPropertyAvailable property="PrjWorkAmountRate" prepend=",">#PrjWorkAmountRate#</isPropertyAvailable>
    <isPropertyAvailable property="PrjContractAmountRate" prepend=",">#PrjContractAmountRate#</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend=",">#Date#</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend=",">#Staff#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="ContractId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTProjectContract" parameterClass="System.Collections.IDictionary">
UPDATE t_project_contract
<include refid="sql_TProjectContract_set_cols"/><!--set-->
<include refid="sql_TProjectContract_where_pk"/><!--where-->
</update>

<delete id="DeleteTProjectContract" parameterClass="">
DELETE FROM t_project_contract
<include refid="sql_TProjectContract_where_pk"/><!--where-->
</delete>

<statement id="DeleteTProjectContract_CV" parameterClass="TProjectContract">
DELETE FROM t_project_contract
<include refid="sql_TProjectContract_where_cv"/><!--where-->
</statement>

<delete id="ClearTProjectContract">
DELETE FROM t_project_contract
</delete>
</statements>
</sqlMap>